//
//  UDButton.m
//  lehuotest
//
//  Created by ice on 2017/1/5.
//  Copyright © 2017年 QF. All rights reserved.
//

#import "UDButton.h"

@implementation UDButton

-(void) layoutSubviews
{
    [super layoutSubviews];
    // Center image
    CGPoint center = self.imageView.center;
    center.x = self.frame.size.width/2;
    center.y = self.imageView.frame.size.height/2+5;
    self.imageView.frame = CGRectMake(0, 0, self.frame.size.height-20, self.frame.size.height-20);
    self.imageView.center = center;

    
    //Center text
    CGRect newFrame = [self titleLabel].frame;
    self.titleLabel.font = [UIFont systemFontOfSize:12];
    newFrame.size.height = 15;
    newFrame.origin.x = 0;
    newFrame.origin.y = self.imageView.frame.size.height + 5;
    newFrame.size.width = self.frame.size.width;
    
    self.titleLabel.frame = newFrame;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
